﻿<?php

include ("../inc/joomlaInt_admin.php");
include("../inc/inc_configuration.php");


if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{

	$reasonId=$_POST["reasonId"];

	if ($reasonId==1)
	{
		$reason="Freiwillige Teamabgabe";
	}
	else
	{
		if ($reasonId==2)
		{
			$reason="Inaktivität";
		}
	}
	 //echo"reason:$reason <br>reasonid: $reasonId";



	$c=$_POST["combination"];

	$tQ="SELECT teamId FROM $tbl_combinations WHERE active=1 AND id=$c";
	$tQe=mysql_query($tQ);
	$tQo=mysql_fetch_object($tQe);

	$tId=$tQo->teamId;

	$q = "SELECT * FROM $tbl_season WHERE active=1";
	$qe = mysql_query($q);
	$qeo = mysql_fetch_object($qe);

	$seasonId = $qeo->id;

	$teamsaender = "UPDATE $tbl_teams set vergeben=0 WHERE id=$tId";
	$combiaender = "UPDATE $tbl_combinations set active=0 WHERE id=$c";

	$eintragen = mysql_query($teamsaender);
	$eintragen = mysql_query($combiaender);


	$time = time();

	$Teintrag = "INSERT INTO $tbl_trainerwechsel (combinationId,type,date,reason,seasonId) VALUES ($c,2,$time,'$reason',$seasonId)";
	$TeintragQ = mysql_query($Teintrag);

	echo 'Sie werden weitergeleitet... <meta http-equiv="refresh" content="2; URL=trainer.php">   ';

}
?>